For this creative assignment, I was interested in looking at datasets from Chicago First I loaded relevant r libraries as well as other r libraries that might be useful to me later on and pulled a world map using the libraries loaded below.
library(osmdata)
library(opentripplanner)
library(tidyverse)
library(sf)
library(ggthemes)
library(ggspatial)
library(sp)
library(stringr)
library(rgeos)
library(tidygeocoder)
dcfarmersmarkets<- st_read(
"https://opendata.arcgis.com/datasets/f2e1c2ef9eb44f2899f4a310a80ecec9_2.kml")
## Reading layer `Farmers_Market_Locations' from data source `https://opendata.arcgis.com/datasets/f2e1c2ef9eb44f2899f4a310a80ecec9_2.kml' using driver `KML'
## Simple feature collection with 62 features and 2 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -77.09596 ymin: 38.82899 xmax: -76.91589 ymax: 38.96517
## geographic CRS: WGS 84
NAD83_Virginia_North <- "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000 +y_0=2000000 +ellps=GRS80 +units=m +no_defs"
dc_street_features <- opq(bbox = 'Washington DC USA') %>%
add_osm_feature(key = 'highway') %>%
osmdata_sf()
dc_streets <- dc_street_features$osm_lines %>%
st_transform(crs = NAD83_Virginia_North)
ggplot(dc_streets) +
geom_sf() +
theme_map()
path_otp <- otp_dl_jar("OTP")
## The OTP will be saved to OTP/otp.jar
path_data <- file.path(getwd(), "OTP")
path_otp <- paste(path_data, "otp.jar",sep = "/")
otp_build_graph(otp = path_otp, dir = path_data, memory = 1024)
## [1] "22:32:49.962 INFO (OTPServer.java:39) Wiring up and configuring server."
## [2] "22:32:49.966 INFO (GraphBuilder.java:165) Wiring up and configuring graph builder task."
## [3] "22:32:49.968 INFO (GraphBuilder.java:171) Searching for graph builder input files in C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default"
## [4] "22:32:49.969 INFO (OTPMain.java:203) File 'C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\build-config.json' is not present. Using default configuration."
## [5] "22:32:49.997 INFO (OTPMain.java:203) File 'C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\router-config.json' is not present. Using default configuration."
## [6] "22:32:50.002 INFO (GraphBuilder.java:184) Summarizing GraphBuilderParameters"
## [7] "htmlAnnotations = false"
## [8] "maxHtmlAnnotationsPerFile = 1000"
## [9] "transit = true"
## [10] "useTransfersTxt = false"
## [11] "parentStopLinking = false"
## [12] "stationTransfers = false"
## [13] "stopClusterMode = proximity"
## [14] "subwayAccessTime = 2.0"
## [15] "streets = true"
## [16] "embedRouterConfig = true"
## [17] "areaVisibility = false"
## [18] "platformEntriesLinking = false"
## [19] "matchBusRoutesToStreets = false"
## [20] "fetchElevationUS = false"
## [21] "elevationBucket = null"
## [22] "elevationUnitMultiplier = 1.0"
## [23] "fareServiceFactory = DefaultFareServiceFactory"
## [24] "customNamer = null"
## [25] "wayPropertySet = org.opentripplanner.graph_builder.module.osm.DefaultWayPropertySetSource@3c09711b"
## [26] "staticBikeRental = false"
## [27] "staticParkAndRide = true"
## [28] "staticBikeParkAndRide = false"
## [29] "maxInterlineDistance = 200"
## [30] "pruningThresholdIslandWithoutStops = 40"
## [31] "pruningThresholdIslandWithStops = 5"
## [32] "banDiscouragedWalking = false"
## [33] "banDiscouragedBiking = false"
## [34] "maxTransferDistance = 2000.0"
## [35] "extraEdgesStopPlatformLink = false"
## [36] ""
## [37] "22:32:50.003 INFO (GraphBuilder.java:193) Found OSM file C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\dc_streets.osm"
## [38] "22:32:50.021 INFO (OpenStreetMapModule.java:161) Gathering OSM from provider: AnyFileBasedOpenStreetMapProviderImpl(C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\dc_streets.osm)"
## [39] "22:32:53.201 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [40] "22:32:53.201 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727264. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [41] "22:32:53.201 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [42] "22:32:53.201 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727269. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [43] "22:32:53.202 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [44] "22:32:53.202 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727273. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [45] "22:32:53.202 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [46] "22:32:53.202 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727276. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [47] "22:32:53.202 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [48] "22:32:53.202 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727279. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [49] "22:32:53.202 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [50] "22:32:53.203 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727281. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [51] "22:32:53.203 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [52] "22:32:53.203 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727287. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [53] "22:32:53.203 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [54] "22:32:53.203 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727294. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [55] "22:32:53.203 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [56] "22:32:53.203 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727295. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [57] "22:32:53.203 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [58] "22:32:53.204 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727379. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [59] "22:32:53.204 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [60] "22:32:53.204 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727381. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [61] "22:32:53.204 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [62] "22:32:53.204 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732250. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [63] "22:32:53.204 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [64] "22:32:53.204 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732252. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [65] "22:32:53.291 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [66] "22:32:53.292 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732263. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [67] "22:32:53.292 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [68] "22:32:53.293 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732264. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [69] "22:32:53.293 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [70] "22:32:53.294 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732265. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [71] "22:32:53.557 WARN (OSMLevel.java:123) Could not determine floor number for layer 6-7, assumed to be ground-level."
## [72] "22:32:53.558 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '6-7' at 615386209. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [73] "22:32:53.558 WARN (OSMLevel.java:123) Could not determine floor number for layer 5-6, assumed to be ground-level."
## [74] "22:32:53.558 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '5-6' at 615386210. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [75] "22:32:53.558 WARN (OSMLevel.java:123) Could not determine floor number for layer 4-5, assumed to be ground-level."
## [76] "22:32:53.558 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '4-5' at 615386211. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [77] "22:32:53.558 WARN (OSMLevel.java:123) Could not determine floor number for layer 3-4, assumed to be ground-level."
## [78] "22:32:53.558 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '3-4' at 615386212. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [79] "22:32:53.559 WARN (OSMLevel.java:123) Could not determine floor number for layer 2-3, assumed to be ground-level."
## [80] "22:32:53.559 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '2-3' at 615386213. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [81] "22:32:53.559 WARN (OSMLevel.java:123) Could not determine floor number for layer 1-2, assumed to be ground-level."
## [82] "22:32:53.559 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '1-2' at 615386214. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [83] "22:32:53.559 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [84] "22:32:53.559 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386220. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [85] "22:32:53.559 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [86] "22:32:53.560 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386221. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [87] "22:32:53.560 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [88] "22:32:53.560 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386222. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [89] "22:32:53.560 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [90] "22:32:53.560 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386223. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [91] "22:32:53.560 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-1, assumed to be ground-level."
## [92] "22:32:53.560 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-1' at 615386227. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [93] "22:32:53.694 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [94] "22:32:53.694 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820430. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [95] "22:32:53.694 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [96] "22:32:53.694 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820431. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [97] "22:32:53.695 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [98] "22:32:53.695 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820432. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [99] "22:32:53.695 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [100] "22:32:53.695 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825087. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [101] "22:32:53.695 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [102] "22:32:53.695 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825088. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [103] "22:32:53.695 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [104] "22:32:53.695 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825089. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [105] "22:32:53.761 WARN (OSMLevel.java:123) Could not determine floor number for layer .5, assumed to be ground-level."
## [106] "22:32:53.761 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '.5' at 769745481. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [107] "22:32:53.761 WARN (OSMLevel.java:123) Could not determine floor number for layer 1.5, assumed to be ground-level."
## [108] "22:32:53.761 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '1.5' at 769745484. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [109] "22:32:53.761 WARN (OSMLevel.java:123) Could not determine floor number for layer 2.5, assumed to be ground-level."
## [110] "22:32:53.762 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '2.5' at 769745486. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [111] "22:32:53.762 WARN (OSMLevel.java:123) Could not determine floor number for layer 3.5, assumed to be ground-level."
## [112] "22:32:53.762 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '3.5' at 769745488. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [113] "22:32:53.765 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [114] "22:32:53.766 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 771016341. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [115] "22:32:58.704 INFO (OSMDatabase.java:315) Intersecting unconnected areas..."
## [116] "22:32:58.985 INFO (OSMDatabase.java:528) Created 0 virtual intersection nodes."
## [117] "22:32:58.986 INFO (OpenStreetMapModule.java:168) Building street graph from OSM"
## [118] "22:33:14.849 INFO (OpenStreetMapModule.java:393) Skipping visibility graph construction for walkable areas and using just area rings for edges."
## [119] "22:33:20.265 INFO (OpenStreetMapModule.java:424) Done building rings for walkable areas."
## [120] "22:33:20.265 INFO (OpenStreetMapModule.java:431) Building P+R areas"
## [121] "22:33:20.265 INFO (OpenStreetMapModule.java:441) Created 0 P+R."
## [122] "22:33:20.268 INFO (OpenStreetMapModule.java:946) graph-wide: Multiplying all bike safety values by 1.6666666"
## [123] "22:33:20.828 INFO (PruneFloatingIslands.java:60) Pruning isolated islands in street network"
## [124] "22:33:21.846 INFO (StreetUtils.java:103) 1072 sub graphs found"
## [125] "22:33:21.996 WARN (StreetUtils.java:125) Removed edgeless vertices after pruning islands"
## [126] "22:33:21.997 INFO (StreetLinkerModule.java:46) Linking transit stops, bike rental stations, bike parking areas, and park-and-rides to graph . . ."
## [127] "22:33:23.491 INFO (Graph.java:963) Summary (number of each type of annotation):"
## [128] "22:33:23.494 INFO (Graph.java:969) GraphConnectivity - 1053"
## [129] "22:33:23.494 INFO (Graph.java:969) Graphwide - 1"
## [130] "22:33:23.494 INFO (Graph.java:969) LevelAmbiguous - 38"
## [131] "22:33:23.527 INFO (Graph.java:814) Main graph size: |V|=247758 |E|=674222"
## [132] "22:33:23.527 INFO (Graph.java:815) Writing graph C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\Graph.obj ..."
## [133] "22:33:25.555 INFO (Graph.java:843) Graph written."
## [134] "22:33:25.556 INFO (GraphBuilder.java:153) Graph building took 0.6 minutes."
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 22:33:26 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 22:34:26 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
iso_5min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "WALK", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North
) %>%
mutate(mode = "walk")
## Warning in otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets, :
## Failed to get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7ff6"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fe8"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fe7"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fe2"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fd4"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fd3"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7fcd"}]}
iso_5min_drive <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "CAR", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North) %>%
mutate(mode = "drive")
## Warning in otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets, :
## Failed to get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-51f1674_174fbf980da_-7f93"}]}
iso_5min_bike <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "BICYCLE", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North) %>%
mutate(mode = "bike")
iso_all_modes <- rbind(iso_5min_drive, iso_5min_walk, iso_5min_bike)
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 38960 has been terminated."
right_side <- st_bbox(iso_all_modes)$xmax
left_side <- st_bbox(iso_all_modes)$xmin
top_side <- st_bbox(iso_all_modes)$ymax
bottom_side <- st_bbox(iso_all_modes)$ymin
ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = dcfarmersmarkets) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By foot", "By bike", "By car")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")
## Loading required namespace: raster
iso_areas <- iso_all_modes %>%
mutate(area = st_area(iso_all_modes)) %>%
st_set_geometry(NULL) %>%
pivot_wider(names_from = mode, values_from = area)
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_point() +
scale_x_continuous(name =
"Area within a five-minute walking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 130000, by = 20000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute driving distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 8 rows containing missing values (geom_point).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_violin() +
scale_x_continuous(name =
"Area within a five-minute walking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 130000, by = 20000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute driving distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 8 rows containing non-finite values (stat_ydensity).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_point() +
stat_smooth(color = "black", linetype = 2, size = 0.5) +
scale_x_continuous(name = "Area within a five-minute walking distance\nof a farmer's market\n(square km)") +
scale_y_continuous(name = "Area within a five-minute driving distance\nof a farmer's market\n(square km)") +
theme_solarized()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 8 rows containing non-finite values (stat_smooth).
## Warning: Removed 8 rows containing missing values (geom_point).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(bike))) +
geom_violin() +
scale_x_continuous(name =
"Area within a five-minute walking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 200000, by = 20000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute biking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 7 rows containing non-finite values (stat_ydensity).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(bike))) +
geom_point() +
stat_smooth(color = "black", linetype = 2, size = 0.5) +
scale_x_continuous(name = "Area within a five-minute walking distance\nof a farmer's market\n(square km)") +
scale_y_continuous(name = "Area within a five-minute biking distance\nof a farmer's market\n(square km)") +
theme_solarized()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing missing values (geom_point).
ggplot(iso_areas,
aes(x = as.numeric(drive), y = as.numeric(bike))) +
geom_violin() +
scale_x_continuous(name =
"Area within a five-minute driving distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 2080000, by = 200000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute biking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 1 rows containing non-finite values (stat_ydensity).
ggplot(iso_areas,
aes(x = as.numeric(drive), y = as.numeric(bike))) +
geom_point() +
stat_smooth(color = "black", linetype = 2, size = 0.5) +
scale_x_continuous(name = "Area within a five-minute driving distance\nof a farmer's market\n(square km)") +
scale_y_continuous(name = "Area within a five-minute biking distance\nof a farmer's market\n(square km)") +
theme_solarized()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
addresslist = c("225 7th St SE, Washington, DC",
"1500 20th St NW, Washington, DC",
"901 23rd St NW, Washington, DC",
"1300 Pennsylvania Ave NW, Washington, DC")
points <- geo(address = addresslist, mode = "batch")
head(points)
## # A tibble: 4 x 3
## address lat long
## <chr> <dbl> <dbl>
## 1 225 7th St SE, Washington, DC 38.9 -77.0
## 2 1500 20th St NW, Washington, DC 38.9 -77.0
## 3 901 23rd St NW, Washington, DC 38.9 -77.1
## 4 1300 Pennsylvania Ave NW, Washington, DC 38.9 -77.0
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 22:35:01 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 22:36:01 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
points <- st_as_sf(x = points,
coords = c("long", "lat"),
crs = 4326)
multiple_points_10min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = points,
mode = "WALK", cutoffSec = 600)
ggplot(multiple_points_10min_walk) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(fill ="orange", alpha=0.2) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
metrostops <- st_read("https://opendata.arcgis.com/datasets/54018b7f06b943f2af278bbe415df1de_52.kml",
quiet=TRUE)
metrostops2 <- st_read("https://opendata.arcgis.com/datasets/ab5661e1a4d74a338ee51cd9533ac787_50.kml",
quiet=TRUE)
multiple_points_10min_walk <- multiple_points_10min_walk %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
ggplot(multiple_points_10min_walk) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill=transit_score), alpha=.5) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
multiple_points_10min_walk2 <- multiple_points_10min_walk %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops2)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
ggplot(multiple_points_10min_walk2) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill=transit_score), alpha=.5) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
dchoods <- st_read("https://opendata.arcgis.com/datasets/f6c703ebe2534fc3800609a07bad8f5b_17.kml",
quiet = TRUE)
dchoods1 <- as(dchoods, "Spatial")
plot(dchoods1)
points1 <-spsample(dchoods1, n=1000, type='regular')
## Warning in proj4string(obj): CRS object has comment, which is lost in output
plot(points1)
points1 <- st_as_sf(x = points1,
coords = coords,
crs = 4326)
iso_10min_walk1 <-
otp_isochrone(otpcon = otpcon, fromPlace = points1,
mode = "WALK", cutoffSec = 600)
## Warning in otp_isochrone(otpcon = otpcon, fromPlace = points1, mode = "WALK", :
## Failed to get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 600},"id":"fid-1ce657f0_174fbfaf998_-7ff8"}]}Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not found:
## [from] vertices not found: [from]
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 28952 has been terminated."
iso_10min_walk1 <- iso_10min_walk1 %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
out <- data.frame(str_split_fixed(iso_10min_walk1$fromPlace, ",", 2))
out <- st_as_sf(x = out,
coords = c("X2", "X1"),
crs = 4326)
out$transit_score <- iso_10min_walk1$transit_score
ggplot(dchoods) +
geom_sf(fill="gray21", color="ivory4")+
geom_sf(data = out, aes(color=transit_score))+
scale_color_gradientn(name="Number of Metro stops\nwithin a 10 min walk", colors=c("steelblue", "gold", "red"))+
theme_map()+
theme(legend.position = c(.7,0),
plot.title = element_text(hjust = 0.5))+
labs(title = "Transit Acessibility Map")
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 22:36:49 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 22:37:49 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
iso_20min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = points1,
mode = "WALK", cutoffSec = 1200)
## Warning in otp_isochrone(otpcon = otpcon, fromPlace =
## points1, mode = "WALK", : Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not found:
## [from] vertices not found: [from]
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 39668 has been terminated."
iso_20min_walk <- iso_20min_walk %>%
mutate(transit_score2 = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
out <- data.frame(str_split_fixed(iso_20min_walk$fromPlace, ",", 2))
out <- st_as_sf(x = out,
coords = c("X2", "X1"),
crs = 4326)
out$transit_score2 <- iso_20min_walk$transit_score2
ggplot(dchoods) +
geom_sf(fill="gray21", color="ivory4")+
geom_sf(data = out, aes(color=transit_score2))+
scale_color_gradientn(name="Number of Metro stops\nwithin a 20 min walk", colors=c("steelblue", "gold", "red"))+
theme_map()+
theme(legend.position = c(.7,0),
plot.title = element_text(hjust = 0.5))+
labs(title = "Transit Acessibility Map")
metrobusstops <- st_read("https://opendata.arcgis.com/datasets/54018b7f06b943f2af278bbe415df1de_52.kml",
quiet=TRUE)